import {Global} from '../../mongodb';
import {ApiCall} from "tsrpc";
import {ReqGet, ResGet} from "../../shared/protocols/teamUser/PtlGet";

export default async function (call: ApiCall<ReqGet, ResGet>) {
    const {userId} = call.req.query;
    // 直接在filter中使用正则表达式匹配name字段，如果name存在的话
    const ret = await Global.db.collection('team_members').aggregate([
        {
            $eq: {
                '$userId':
                userId
            }
        }
    ]).explain()

    return call.succ({
        data: ret[0].data
    });
}